package com.ejd.utils;

import java.util.Iterator;
import java.util.List;
import java.util.Set;

import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;


import com.ejd.service.IDeliveryService;
import com.ejd.web.bo.impl.Delivery;
import com.ejd.web.constant.ManageBeanConstants;
import com.ejd.web.constant.SpringBeanConstants;
import com.ejd.web.vo.common.LocalBean;


public final class PageExistUtil {
	public PageExistUtil() {
	  }
	public static boolean checkPageExist(String fileName,String pathParam){
		boolean result = false;
		try	{
			FacesContext facesContext = FacesContext.getCurrentInstance();
			ExternalContext externalContext = facesContext.getExternalContext();
			Set resourcePaths = externalContext.getResourcePaths(pathParam);
			Iterator iterator = resourcePaths.iterator(); 
			while (iterator.hasNext()) {
				String path = (String) iterator.next();
				String tempFileName = path.substring(pathParam.length()+1, path.length());
				
				if (tempFileName.equals(fileName)) {
					result = true;
					if (result) {
						break;
					}
				}
				System.out.println(path);
			} 
			return result;
		}
		catch(Exception	e){  
			e.printStackTrace();  
	        return   false;  
	    }  
	}

}
